#include <iostream>
#include <algorithm>

using namespace std;

const int N = 10010;

int n, m, w;
int p[N];
int d[N], v[N];
int f[N];

int find(int x) {
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}

int main() {
    cin >> n >> m >> w;
    
    for (int i = 1; i <= n; ++ i) p[i] = i;
    for (int i = 1; i <= n; ++ i) scanf("%d%d", &d[i], &v[i]);
    
    while (m -- ) {
        int a, b;
        scanf("%d%d", &a, &b);
        int pa = find(a), pb = find(b);
        if (pa != pb) {
            d[pb] += d[pa], v[pb] += v[pa];
            p[pa] = pb;
        }
    }
    
    for (int i = 1; i <= n; ++ i)
        if (p[i] == i)
            for (int j = w; j >= d[i]; -- j)
                f[j] = max(f[j], f[j - d[i]] + v[i]);
    
    cout << f[w] << endl;
    
    return 0;
}